#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/10/19 14:38
# @Author  : Crissu
# @Site    : 
# @File    : makeSmallTest.py
# @Software: PyCharm
import os, random, cv2
import PIL.Image as Image

path = "C:/sjj/workspace/dataset/linyehaichong/croped_selected85_resized_tvt/test/"
savePath = "C:/sjj/workspace/dataset/linyehaichong/croped_selected85_resized_tvt/smalltest/"



classNames = os.listdir(path)
for claName in classNames:
    print(claName)
    imgsPath = path + claName + "/"
    imgNames = os.listdir(imgsPath)
    rndList = list()
    for i in range(1):
        rnd = random.randint(0, len(imgNames) - 1)
        rndList.append(rnd)
    print(rndList)
    for j in rndList:
        name = imgNames[j]
        picPath = imgsPath + name
        savePicPath = savePath + claName + "/"
        if not os.path.exists(savePicPath):
            os.makedirs(savePicPath)

        image = cv2.imread(picPath)
        savePicName = savePicPath + name
        cv2.imwrite(savePicName, image)

